
# generate figure 4

# load packages
library(rio) # load data
library(tidyverse) # data manipulation
library(scales) # better breaks for plots

# set working directory
setwd("~/replication_files/")

# load data on the dependent variable
dv <- read_csv("data/fund_laws.csv") %>%
  dplyr::select(country,year,month) %>%
  filter(year > 2003 & year < 2020 & country!="Eritrea" & country!="Turkmenistan" & country!="Venezuela") %>% # removing countries for which no consultations are available
  unique() %>%
  group_by(year) %>%
  count()

ggplot(dv, aes(x=year,y=n)) + geom_col() + 
  labs(x="Year",y="Number of Legal Documents") +
  theme_classic() + scale_y_continuous(breaks=pretty_breaks()) +
  theme(axis.text.x = element_text(size=12), 
        axis.text.y = element_text(size=12),
        axis.title.x = element_text(size=12),
        axis.title.y = element_text(size=12)) + 
  scale_x_continuous(breaks = c(2004,2009,2014,2019))

ggsave("figures/fig4.pdf", height = 5, width = 9)
